#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   run.py
@Time    :   2020/09/22 10:57:23
@Author  :   fengzhilaoling 
@Version :   1.0
@Contact :   fengzhilaoling@163.com
'''
from flask import Flask
from exts import db
import pymysql
import os
import sys

cur_dir = os.path.dirname(__file__)
conf_dir = os.path.join(cur_dir, 'config')
sys.path.append(conf_dir)
from config import DevelopmentConfig
from views.userLogin import user_bp
from flask import session
from flask import redirect
from flask import render_template
from flask import url_for
from flask import request

app = Flask(__name__)
app.config.from_object(DevelopmentConfig)  # 导入数据库配置
db.init_app(app)  # 数据库初始化当前应用


# @app.before_request
# def auto():
#     request_path = request.path
#     if request_path == '/user/login/' or request_path == '/user/add/':
#         print('ccc')
#         return None
#
#     else:
#         login_status = session.get('login_status')
#         print(login_status)
#         if login_status:
#             print('bbb')
#             return redirect(url_for('user.login'))
#         else:
#             print('aaa')
#             return redirect(url_for('user.login'))


app.register_blueprint(user_bp, url_prefix='/user')

if __name__ == '__main__':
    app.run()
